/*
 * Alipay.com Inc. Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.company.exception.base;

/**
 * 系统异常类
 *
 * @author poc
 * @version : SystemException.java, v 0.1 2023年12月15日 16:11:961 poc Exp $
 */
public class SystemException extends AbstractBaseException {

    /**
     * 系统异常一般可以重试
     */
    private static final boolean CAN_RETRY = true;

    /**
     * Constructs a new runtime exception with {@code null} as its detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     *
     * @param enumCode 错误码
     */
    public SystemException(IResultCode enumCode) {
        super(enumCode.getCode(), CAN_RETRY);
    }

    /**
     * Constructs a new runtime exception with {@code null} as its detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     *
     * @param code 错误码
     */
    public SystemException(String code) {
        super(code, CAN_RETRY);
    }

    /**
     * Constructs a new runtime exception with {@code null} as its detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     *
     * @param enumCode 错误码
     * @param canRetry 自定义是否重试
     */
    public SystemException(IResultCode enumCode, Boolean canRetry) {
        super(enumCode.getCode(), canRetry);
    }

    /**
     * Constructs a new runtime exception with {@code null} as its detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     *
     * @param code     错误码
     * @param canRetry 自定义是否重试
     */
    public SystemException(String code, Boolean canRetry) {
        super(code, canRetry);
    }

    /**
     * 构造函数
     *
     * @param enumCode    错误码
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(IResultCode enumCode, Object... placeHolder) {
        super(enumCode.getCode(), CAN_RETRY, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param code        错误码
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(String code, Object... placeHolder) {
        super(code, CAN_RETRY, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param enumCode    错误码
     * @param canRetry    自定义是否重试
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(IResultCode enumCode, Boolean canRetry, Object... placeHolder) {
        super(enumCode.getCode(), canRetry, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param code        错误码
     * @param canRetry    自定义是否重试
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(String code, Boolean canRetry, Object... placeHolder) {
        super(code, canRetry, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param enumCode    错误码
     * @param cause       throwable
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(IResultCode enumCode, Throwable cause, Object... placeHolder) {
        super(enumCode.getCode(), CAN_RETRY, cause, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param code        错误码
     * @param cause       throwable
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(String code, Throwable cause, Object... placeHolder) {
        super(code, CAN_RETRY, cause, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param enumCode    错误码
     * @param canRetry    自定义是否重试
     * @param cause       throwable
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(IResultCode enumCode, Boolean canRetry, Throwable cause, Object... placeHolder) {
        super(enumCode.getCode(), canRetry, cause, placeHolder);
    }

    /**
     * 构造函数
     *
     * @param code        错误码
     * @param canRetry    自定义是否重试
     * @param cause       throwable
     * @param placeHolder 错误码占位符,例如{0}业务异常,按顺序传入的参数
     */
    public SystemException(String code, Boolean canRetry, Throwable cause, Object... placeHolder) {
        super(code, canRetry, cause, placeHolder);
    }

}